<!--
 * @Author: 姚贤通 10254465+yao-xiantong@user.noreply.gitee.com
 * @Date: 2022-11-15 13:24:03
 * @LastEditors: panda-hbd 1511539537@qq.com
 * @LastEditTime: 2022-11-16 15:03:17

 
 * @LastEditors: panda-hbd 1511539537@qq.com
 * @LastEditTime: 2022-11-16 11:20:52
>>>>>>> e143db08c9b09eb6eb1041b520fcddb588b48be9
 * @FilePath: \vue\src\views\Talk\Details.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- <template>
    <div style="width: 85rem;height: rem;background-color: white;padding: 1.5rem;
    border-radius: 0.3rem;box-shadow: 0rem 0.1rem 0.1rem 0.1rem rgb(199, 199, 199);">
        头部 -->
        <!-- <header style="display: flex;align-items: center;margin-bottom: 1rem;margin-left: 0.5rem;">
            <h3 style="color: black;">讨论区</h3>
            <p style="font-size: 1rem;color: dimgrey;">——— 主题详情</p>
        </header>
        <hr>
        主题问题 -->


        <!-- 主题回复 -->
    <!-- </div>
</template> -->
<template>
    <el-card class="box-card"> 
 <!-- 头部 -->
      <template #header>
        <div class="card-header" style="display: flex;align-items: center;margin-bottom: 0.5rem;margin-left: 0.5rem;">
          <span>讨论区</span>
          <p style="font-size: 1rem;color: dimgrey;">——— 主题详情</p>
        </div>
      </template>
    <el-scrollbar height="28rem">
      <!-- 问题区 -->
      <div style="width: 100%;background-color: rgb(200, 200, 200);padding: 1rem;margin-bottom: 1rem;position: relative;">
        <h3 style="margin-bottom: 1rem;color: black;">{{ discusstion.title}}</h3>

            <div style="color: rgb(80, 80, 80);font-size: 0.8rem;" ref="content"></div>
 
        <br>
        <br>
        <el-button @click="ToTrue" type="primary" plain style="position: absolute;height: 1.5rem;font-size: 0.7rem;display: flex;align-items: center;bottom: 1rem;right: 1rem;">
            <el-icon style="font-size: 0.8rem;margin-right: 0.2rem;"><ChatDotRound /></el-icon>回复
        </el-button>
      </div>

      <!-- 回复编辑区 -->
      <div v-if="flag" style="position: relative;">
        <textarea name="" id="" cols="171" rows="10"></textarea>
        <br><br><br><br><br>
        <div style="position: absolute;bottom: 1rem;right: 1rem;">
            <el-button style="color: rgb(32, 80, 192);border: 1px solid rgb(32, 80, 192);font-size: 0.8rem;" @click="ToFalse">取消</el-button>
            <el-button type="primary" style="font-size: 0.8rem;">回复</el-button>
        </div>
      </div>
      
      <!-- 全部回复区 -->
      <div>
        <h3>全部回复</h3>
        <hr style="margin-top: 1rem;">
        <div class="demo-collapse">
    <el-collapse v-model="activeNames" @change="handleChange">
      <el-collapse-item :name="index" v-for="(user,index) in allReplyData" :key="index">
        <template #title>
            <img src="https://source.unsplash.com/WLUHO9A_xik/400x300" style="height: 2rem;width: 2rem;border-radius: 50%;margin-right: 0.5rem;" alt="">
          {{user.name}}
            <span style="margin-left: 1rem;">{{user.content}}</span>
        </template>
        <div style="margin-left: 2rem;position: relative;">
            {{user.content}}
            <br><br><br>
            <div style="position: absolute;right: 1rem;bottom: 0.2rem;align-items: center;display: flex;">
                <img src="../../../public/img/点赞(1).png" style="height: 1rem;width: 1rem;" alt="">
                <span style="margin-left: 0.5rem;margin-right: 1rem;">{{user.likes}}</span>
                <img src="../../../public/img/差评.png" style="height: 1rem;width: 1rem;" alt="">
                <span style="margin-left: 0.5rem;">{{user.dislikes}}</span>
            </div>
        </div>
      </el-collapse-item>
      
    </el-collapse>
  </div>
      </div>
    </el-scrollbar>
      
    </el-card>
  </template>

<script>

import {mapGetters} from 'vuex'
import reply from '../../api/reply.js'
import discusstion from '../../api/discusstion.js'

export default {
    name: 'DetailsVue',

    data() {
        return {
            flag:false,
            discusstion:'',
            allReplyData:[]
        };
    },

    //挂载方法
    mounted() {

      //初始化详情
        discusstion.getDiscusstionById(this.getCurrentDiscusstionId).then((res)=>{
                if(res.code == 1){
                  this.discusstion = res.data
                  this.$refs.content.innerHTML = this.discusstion.content
                  this.initReplyData()
                }
                
        })
        
        

    },

    computed:{
      ...mapGetters(['getCurrentDiscusstionId'])
    }
    ,
    methods: {

       initReplyData(){
            reply.getAllRepliesByDiscusstionId(this.discusstion.id).then((res)=>{
                  if(res.code == 1)
                     this.allReplyData = res.data
            })
       }
       ,

        ToTrue(){
            this.flag = true;
        },
        ToFalse(){
            this.flag = false;
        }
        ,
        
    },
};
</script>

<style scoped>
.card-header {
  display: flex;
  /* justify-content: space-between; */
  align-items: center
} 

.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.box-card {
    width: 83rem;
    padding: 1rem;
} 

.el-card{
  position: fixed;
  top: 8rem;
}
</style>